﻿namespace ControleRepresentante.Logic.Models.Maps
{
    public class IndexColumnsPreferenceMap : MapBase<IndexColumnsPreference>
    {
        public IndexColumnsPreferenceMap()
        {
            References(x => x.User)
                .Not.Nullable();
            Map(x => x.Area)
                .CustomType(typeof(Area))
                .Not.Nullable();
            HasMany(x => x.BuiltInIndexColumnPreferences)
                .Inverse()
                .Cascade.AllDeleteOrphan();
            HasMany(x => x.AttributeIndexColumnPreferences)
                .Inverse()
                .Cascade.AllDeleteOrphan();
        }
    }

    public class BuiltInIndexColumnPreferenceMap : MapBase<BuiltInIndexColumnPreference>
    {
        public BuiltInIndexColumnPreferenceMap()
        {
            References(x => x.IndexColumnsPreference)
                .Not.Nullable();
            Map(x => x.ColumnId)
                .Not.Nullable();
        }
    }

    public class AttributeIndexColumnPreferenceMap : MapBase<AttributeIndexColumnPreference>
    {
        public AttributeIndexColumnPreferenceMap()
        {
            References(x => x.IndexColumnsPreference)
                .Not.Nullable();
            References(x => x.Attribute)
                .Not.Nullable();
        }
    }
}